<?php
chdir('../');

require('includes/setUp.php');

try {

  $photo = new Photo();
  $photo = $db->find('Photo', $_GET['idPhoto']);

  $rate = round(($photo->AverageRating / 5)*100);
  
  $query = $db->createQuery('SELECT COUNT(r.idRating) FROM Rating r JOIN r.user u JOIN r.photo p WHERE u.idUser = ?1 AND p.idPhoto = ?2');
  $query->setParameter(1, $user->idUser);
  $query->setParameter(2, $photo->idPhoto);
  $isRated = $query->getSingleScalarResult();
  $isRated = $isRated > 0;
 
 
  
  include ('includes/views/title.php');
  
} catch (Exception $ex) {
  globalFunc::redirect(WebRoot.'index.php?errMsg='.rawurlencode($ex->getMessage()));
}